home *** CD-ROM | disk | FTP | other *** search
/ Aminet 1 (Walnut Creek) / Aminet - June 1993 [Walnut Creek].iso / aminet / dev / debug / mykes_gtb.lha / scroller.c < prev    next >
C/C++ Source or Header  |  1992-03-02  |  24KB  |  680 lines

  1. /*-- AutoRev header do NOT edit!
  2. *
  3. *   Program         :   Scroller.c
  4. *   Copyright       :   © Copyright 1991 Jaba Development
  5. *   Author          :   Jan van den Baard
  6. *   Creation Date   :   07-Oct-91
  7. *   Current version :   1.00
  8. *   Translator      :   DICE v2.6
  9. *
  10. *   REVISION HISTORY
  11. *
  12. *   Date          Version         Comment
  13. *   ---------     -------         ------------------------------------------
  14. *   07-Oct-91     1.00            Scroller editor.
  15. *
  16. *-- REV_END --*/
  17.  
  18. #include    "defs.h"
  19.  
  20. /*
  21.  * --- External referenced data
  22.  */
  23. extern ULONG                Class;
  24. extern UWORD                Code;
  25. extern struct Gadget       *theObject;
  26. extern APTR                 MainVisualInfo;
  27. extern struct TextAttr      Topaz80;
  28. extern struct Screen       *MainScreen;
  29. extern struct Window       *MainWindow;
  30. extern UWORD                ngFlags;
  31. extern WORD                 ngLeft, ngTop, ngWidth, ngHeight;
  32. extern UBYTE               *PlaceList[];
  33. extern UWORD                PlaceFlags[];
  34. extern struct ExtGadgetList Gadgets;
  35. extern BOOL                 Saved;
  36.  
  37. /*
  38.  * --- Gadget ID's
  39.  */
  40. #define GD_TEXT             0
  41. #define GD_LABEL            1
  42. #define GD_UNDERSCORE       2
  43. #define GD_DISABLED         3
  44. #define GD_HIGHLABEL        4
  45. #define GD_IMMEDIATE        5
  46. #define GD_RELVERIFY        6
  47. #define GD_LORIENT          7
  48. #define GD_TOP              8
  49. #define GD_TOTAL            9
  50. #define GD_VISIBLE          10
  51. #define GD_ARROWS           11
  52. #define GD_TEXTPLACE        12
  53. #define GD_OK               13
  54. #define GD_CANCEL           14
  55.  
  56. /*
  57.  * --- Module data
  58.  */
  59. struct Window              *sr_Wnd    = NULL;
  60. struct Gadget              *sr_GList  = NULL;
  61. struct Gadget              *sr_Gadgets[13];
  62. BOOL                        sr_Score = FALSE, sr_Disabled = FALSE;
  63. BOOL                        sr_Immediate = FALSE;
  64. BOOL                        sr_RelVerify = FALSE;
  65. UWORD                       sr_Lorient = LORIENT_HORIZ;
  66. WORD                        sr_Zoom[4];
  67. UBYTE                      *sr_Free[] = {
  68.     "Hori_zontal", "_Vertical  ", 0l };
  69.  
  70. struct TagItem              sr_nwTags[] = {
  71.     WA_Left,                0l,
  72.     WA_Top,                 0l,
  73.     WA_Width,               0l,
  74.     WA_Height,              0l,
  75.     WA_IDCMP,               IDCMP_CLOSEWINDOW | CYCLEIDCMP | BUTTONIDCMP | CHECKBOXIDCMP | MXIDCMP | IDCMP_REFRESHWINDOW | IDCMP_VANILLAKEY,
  76.     WA_Flags,               WFLG_DRAGBAR | WFLG_DEPTHGADGET | WFLG_CLOSEGADGET | WFLG_SMART_REFRESH | WFLG_ACTIVATE | WFLG_RMBTRAP,
  77.     WA_Gadgets,             0l,
  78.     WA_Title,               (ULONG)"Edit SCROLLER gadget:",
  79.     WA_AutoAdjust,          TRUE,
  80.     WA_Zoom,                (Tag)sr_Zoom,
  81.     WA_CustomScreen,        0l,
  82.     TAG_DONE };
  83.  
  84. /*
  85.  * --- Create the scroller gadget.
  86.  */
  87. long MakeScroller( void )
  88. {
  89.     struct ExtNewGadget *eng  = 0l;
  90.     struct TagItem      *tags = 0l;
  91.  
  92.     if ( eng = Malloc((long)sizeof( struct ExtNewGadget ))) {
  93.         if ( tags = MakeTagList( 9l )) {
  94.  
  95.             eng->en_NumTags = 9l;
  96.             eng->en_Tags = tags;
  97.  
  98.             ChangeScroller( eng );
  99.  
  100.             RemoveAllGadgets();
  101.  
  102.             AddTail(( struct List * )&Gadgets, ( struct Node * )eng );
  103.  
  104.             Renumber();
  105.  
  106.             if ( RemakeAllGadgets())
  107.                 return TRUE;
  108.  
  109.             Remove(( struct Node * )eng);
  110.         }
  111.     }
  112.  
  113.     MyRequest( "Ahem....", "CONTINUE", "Out of memory !" );
  114.  
  115.     if ( tags )         FreeTagList( tags, 9l );
  116.     if ( eng  )         free( eng );
  117.  
  118.     return FALSE;
  119. }
  120.  
  121. /*
  122.  * --- Change the scroller gadget.
  123.  */
  124. void ChangeScroller( struct ExtNewGadget *eng )
  125. {
  126.     struct TagItem      *tags;
  127.     UBYTE               *slab, *text, tn = 0;
  128.     long                 num;
  129.  
  130.     tags = eng->en_Tags;
  131.  
  132.     slab = (( struct StringInfo * )sr_Gadgets[ GD_LABEL ]->SpecialInfo )->Buffer;
  133.     text = (( struct StringInfo * )sr_Gadgets[ GD_TEXT  ]->SpecialInfo )->Buffer;
  134.  
  135.     eng->en_NewGadget.ng_LeftEdge   =   ngLeft;
  136.     eng->en_NewGadget.ng_TopEdge    =   ngTop;
  137.     eng->en_NewGadget.ng_Width      =   ngWidth;
  138.     eng->en_NewGadget.ng_Height     =   ngHeight;
  139.  
  140.     if ( strncmp( slab, "Gadget", 6 ) && strlen( slab )) {
  141.         strcpy( &eng->en_SourceLabel[0], slab );
  142.         eng->en_SpecialFlags |= EGF_USERLABEL;
  143.     } else
  144.         eng->en_SpecialFlags = 0l;
  145.  
  146.     if ( strlen( text )) {
  147.         strcpy( &eng->en_GadgetText[0], text );
  148.         eng->en_NewGadget.ng_GadgetText = &eng->en_GadgetText[0];
  149.         eng->en_NewGadget.ng_Flags      = ngFlags;
  150.     } else {
  151.         eng->en_NewGadget.ng_GadgetText = 0l;
  152.         eng->en_NewGadget.ng_Flags      = 0;
  153.     }
  154.  
  155.     eng->en_Kind    = SCROLLER_KIND;
  156.  
  157.     if ( sr_Score && strlen( text )) {
  158.         tags[ tn   ].ti_Tag  = GT_Underscore;
  159.         tags[ tn++ ].ti_Data = (Tag)'_';
  160.     }
  161.  
  162.     if ( sr_Disabled )
  163.         eng->en_SpecialFlags |= EGF_DISABLED;
  164.  
  165.     if ( NOT sr_RelVerify )
  166.         eng->en_SpecialFlags |= EGF_NOGADGETUP;
  167.  
  168.     tags[ tn   ].ti_Tag  = GA_RelVerify;
  169.     tags[ tn++ ].ti_Data = TRUE;
  170.  
  171.     if ( sr_Immediate ) {
  172.         tags[ tn   ].ti_Tag  = GA_Immediate;
  173.         tags[ tn++ ].ti_Data = TRUE;
  174.     }
  175.  
  176.     if ( sr_Lorient == LORIENT_VERT ) {
  177.         tags[ tn   ].ti_Tag  = PGA_Freedom;
  178.         tags[ tn++ ].ti_Data = sr_Lorient;
  179.     }
  180.  
  181.     num = (( struct StringInfo * )sr_Gadgets[ GD_TOP ]->SpecialInfo )->LongInt;
  182.  
  183.     if ( num ) {
  184.         tags[ tn   ].ti_Tag  = GTSC_Top;
  185.         tags[ tn++ ].ti_Data = num;
  186.     }
  187.  
  188.     num = (( struct StringInfo * )sr_Gadgets[ GD_TOTAL ]->SpecialInfo )->LongInt;
  189.  
  190.     if ( num ) {
  191.         tags[ tn   ].ti_Tag  = GTSC_Total;
  192.         tags[ tn++ ].ti_Data = num;
  193.     }
  194.  
  195.     num = (( struct StringInfo * )sr_Gadgets[ GD_VISIBLE ]->SpecialInfo )->LongInt;
  196.  
  197.     if ( num != 2 ) {
  198.         tags[ tn   ].ti_Tag  = GTSC_Visible;
  199.         tags[ tn++ ].ti_Data = num;
  200.     }
  201.  
  202.     num = (( struct StringInfo * )sr_Gadgets[ GD_ARROWS ]->SpecialInfo )->LongInt;
  203.  
  204.     if ( num > 7 ) {
  205.         eng->en_ArrowSize = num;
  206.         tags[ tn   ].ti_Tag  = GTSC_Arrows;
  207.         tags[ tn++ ].ti_Data = num;
  208.     }
  209.  
  210.     tags[ tn ].ti_Tag = TAG_DONE;
  211.  
  212.     Saved = FALSE;
  213. }
  214.  
  215. /*
  216.  * --- Open the EditScroller requester.
  217.  */
  218. long EditScroller( WORD x, WORD y, WORD x1, WORD y1, struct Gadget *edit )
  219. {
  220.     struct Gadget       *g;
  221.     struct ExtNewGadget *e;
  222.     struct NewGadget     ng;
  223.     BOOL                 running = TRUE, ok = FALSE, high = FALSE;
  224.     WORD                 l, t, w, h, btop, bleft, gw, gh;
  225.     UBYTE               *label = 0l, *slabel = 0l, *cycle;
  226.     Tag                  place = 0l, num;
  227.     UWORD                flag  = PLACETEXT_LEFT, ID;
  228.     UWORD                top = 0, total = 0, visible = 2, arrows = 8;
  229.  
  230.     cycle = (UBYTE *)&PlaceList[1];
  231.  
  232.     if ( edit ) {
  233.         e = FindExtGad( edit );
  234.  
  235.         x  = e->en_NewGadget.ng_LeftEdge;
  236.         y  = e->en_NewGadget.ng_TopEdge;
  237.         gw = e->en_NewGadget.ng_Width;
  238.         gh = e->en_NewGadget.ng_Height;
  239.  
  240.         label  = &e->en_GadgetText[0];
  241.         slabel = &e->en_SourceLabel[0];
  242.  
  243.         flag = e->en_NewGadget.ng_Flags;
  244.  
  245.         if ( flag & PLACETEXT_LEFT  ) place = 0l;
  246.         if ( flag & PLACETEXT_RIGHT ) place = 1l;
  247.         if ( flag & PLACETEXT_ABOVE ) place = 2l;
  248.         if ( flag & PLACETEXT_BELOW ) place = 3l;
  249.  
  250.         if ( flag & NG_HIGHLABEL    ) high = TRUE;
  251.  
  252.         sr_Score     = MyTagInArray( GT_Underscore, e->en_Tags );
  253.         sr_Immediate = MyTagInArray( GA_Immediate,  e->en_Tags );
  254.         sr_RelVerify = MyTagInArray( GA_RelVerify,  e->en_Tags );
  255.  
  256.         if (( e->en_SpecialFlags & EGF_NOGADGETUP ) == EGF_NOGADGETUP )
  257.             sr_RelVerify = FALSE;
  258.  
  259.         if ( MyTagInArray( PGA_Freedom, e->en_Tags ))
  260.             sr_Lorient = LORIENT_VERT;
  261.         else
  262.             sr_Lorient = LORIENT_HORIZ;
  263.  
  264.         top     = GetTagData( GTSC_Top,     0, e->en_Tags );
  265.         total   = GetTagData( GTSC_Total,   0, e->en_Tags );
  266.         visible = GetTagData( GTSC_Visible, 2, e->en_Tags );
  267.         arrows  = GetTagData( GTSC_Arrows,  8, e->en_Tags );
  268.  
  269.         if (( e->en_SpecialFlags & EGF_DISABLED ) == EGF_DISABLED )
  270.             sr_Disabled = TRUE;
  271.         else
  272.             sr_Disabled = FALSE;
  273.  
  274.     } else {
  275.         if ( x > x1 ) { gw = x; x = x1; x1 = gw; }
  276.         if ( y > y1 ) { gh = y; y = y1; y1 = gh; }
  277.  
  278.         gw = x1 - x + 1;
  279.         gh = y1 - y + 1;
  280.     }
  281.  
  282.     btop  = MainScreen->WBorTop + 1 + MainScreen->RastPort.TxHeight;
  283.     bleft = MainScreen->WBorLeft;
  284.  
  285.     w = bleft + MainScreen->WBorRight  + 300;
  286.     h = btop  + MainScreen->WBorBottom + 182;
  287.     l = (( MainScreen->Width  >> 1 ) - ( w >> 1 ));
  288.     t = (( MainScreen->Height >> 1 ) - ( h >> 1 ));
  289.  
  290.     sr_Zoom[0] = 0;
  291.     sr_Zoom[1] = btop;
  292.     sr_Zoom[2] = 200;
  293.     sr_Zoom[3] = btop;
  294.  
  295.     sr_nwTags[0 ].ti_Data = l;
  296.     sr_nwTags[1 ].ti_Data = t;
  297.     sr_nwTags[2 ].ti_Data = w;
  298.     sr_nwTags[3 ].ti_Data = h;
  299.     sr_nwTags[10].ti_Data = (Tag)MainScreen;
  300.  
  301.     if ( g = CreateContext( &sr_GList ))  {
  302.  
  303.         ng.ng_LeftEdge      =   bleft + 56;
  304.         ng.ng_TopEdge       =   btop + 4;
  305.         ng.ng_Width         =   236;
  306.         ng.ng_Height        =   12;
  307.         ng.ng_GadgetText    =   "_Text ";
  308.         ng.ng_TextAttr      =   &Topaz80;
  309.         ng.ng_GadgetID      =   GD_TEXT;
  310.         ng.ng_Flags         =   PLACETEXT_LEFT;
  311.         ng.ng_VisualInfo    =   MainVisualInfo;
  312.         ng.ng_UserData      =   0l;
  313.  
  314.         g = CreateGadget( STRING_KIND, g, &ng, GTST_String, (Tag)label, GTST_MaxChars, (Tag)GT_MAXLABELNAME + 1, GT_Underscore, (Tag)'_', TAG_DONE );
  315.  
  316.         SetStringGadget( g );
  317.  
  318.         sr_Gadgets[ GD_TEXT ] = g;
  319.  
  320.         ng.ng_TopEdge       =   btop + 20;
  321.         ng.ng_GadgetText    =   "_Label";
  322.         ng.ng_GadgetID      =   GD_LABEL;
  323.  
  324.         g = CreateGadget( STRING_KIND, g, &ng, GTST_String, (Tag)slabel, GTST_MaxChars, (Tag)GT_MAXLABEL + 1, GT_Underscore, (Tag)'_', TAG_DONE );
  325.  
  326.         SetStringGadget( g );
  327.  
  328.         sr_Gadgets[ GD_LABEL ] = g;
  329.  
  330.         ng.ng_LeftEdge      =   bleft + 96;
  331.         ng.ng_TopEdge       =   btop + 36;
  332.         ng.ng_GadgetText    =   "_Underscore";
  333.         ng.ng_GadgetID      =   GD_UNDERSCORE;
  334.  
  335.         g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, (Tag)sr_Score, GT_Underscore, (Tag)'_', TAG_DONE );
  336.  
  337.         sr_Gadgets[ GD_UNDERSCORE ] = g;
  338.  
  339.         ng.ng_LeftEdge      =   bleft + 266;
  340.         ng.ng_GadgetText    =   "_Disabled  ";
  341.         ng.ng_GadgetID      =   GD_DISABLED;
  342.  
  343.         g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, (Tag)sr_Disabled, GT_Underscore, (Tag)'_', TAG_DONE );
  344.  
  345.         sr_Gadgets[ GD_DISABLED ] = g;
  346.  
  347.         ng.ng_LeftEdge      =   bleft + 96;
  348.         ng.ng_TopEdge       =   btop + 51;
  349.         ng.ng_GadgetText    =   "_High Label";
  350.         ng.ng_GadgetID      =   GD_HIGHLABEL;
  351.  
  352.         g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, (Tag)high, GT_Underscore, '_', TAG_DONE );
  353.  
  354.         sr_Gadgets[ GD_HIGHLABEL ] = g;
  355.  
  356.         ng.ng_LeftEdge      =   bleft + 266;
  357.         ng.ng_GadgetText    =   "_Immediate ";
  358.         ng.ng_GadgetID      =   GD_IMMEDIATE;
  359.  
  360.         g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, (Tag)sr_Immediate, GT_Underscore, '_', TAG_DONE );
  361.  
  362.         sr_Gadgets[ GD_IMMEDIATE ] = g;
  363.  
  364.         ng.ng_LeftEdge      =   bleft + 96;
  365.         ng.ng_TopEdge       =   btop +  66;
  366.         ng.ng_GadgetText    =   "_Relverify ";
  367.         ng.ng_GadgetID      =   GD_RELVERIFY;
  368.  
  369.         g = CreateGadget( CHECKBOX_KIND, g, &ng, GTCB_Checked, (Tag)sr_RelVerify, GT_Underscore, '_', TAG_DONE );
  370.  
  371.         sr_Gadgets[ GD_RELVERIFY ] = g;
  372.  
  373.         ng.ng_TopEdge       =   btop + 64;
  374.         ng.ng_LeftEdge      =   bleft + 266;
  375.         ng.ng_GadgetText    =   0l;
  376.         ng.ng_GadgetID      =   GD_LORIENT;
  377.  
  378.         g = CreateGadget( MX_KIND, g, &ng, GTMX_Labels, sr_Free, GTMX_Active, (Tag)sr_Lorient - 1, GT_Underscore, '_', TAG_DONE );
  379.  
  380.         sr_Gadgets[ GD_LORIENT ] = g;
  381.  
  382.         ng.ng_LeftEdge      =   bleft + 96;
  383.         ng.ng_TopEdge       =   btop + 84;
  384.         ng.ng_Width         =   196;
  385.         ng.ng_Height        =   12;
  386.         ng.ng_GadgetText    =   "To_p       ";
  387.         ng.ng_GadgetID      =   GD_TOP;
  388.  
  389.         g = CreateGadget( INTEGER_KIND, g, &ng, GTIN_Number, top, GTIN_MaxChars, 5l, GT_Underscore, '_', TAG_DONE );
  390.  
  391.         SetStringGadget( g );
  392.  
  393.         sr_Gadgets[ GD_TOP ] = g;
  394.  
  395.         ng.ng_TopEdge       =   btop + 100;
  396.         ng.ng_GadgetText    =   "Tot_al     ";
  397.         ng.ng_GadgetID      =   GD_TOTAL;
  398.  
  399.         g = CreateGadget( INTEGER_KIND, g, &ng, GTIN_Number, total, GTIN_MaxChars, 5l, GT_Underscore, '_', TAG_DONE );
  400.  
  401.         SetStringGadget( g );
  402.  
  403.         sr_Gadgets[ GD_TOTAL ] = g;
  404.  
  405.         ng.ng_TopEdge       =   btop + 116;
  406.         ng.ng_GadgetText    =   "Vi_sible   ";
  407.         ng.ng_GadgetID      =   GD_VISIBLE;
  408.  
  409.         g = CreateGadget( INTEGER_KIND, g, &ng, GTIN_Number, visible, GTIN_MaxChars, 5l, GT_Underscore, '_', TAG_DONE );
  410.  
  411.         SetStringGadget( g );
  412.  
  413.         sr_Gadgets[ GD_VISIBLE ] = g;
  414.  
  415.         ng.ng_TopEdge       =   btop + 132;
  416.         ng.ng_GadgetText    =   "Arro_ws    ";
  417.         ng.ng_GadgetID      =   GD_ARROWS;
  418.  
  419.         g = CreateGadget( INTEGER_KIND, g, &ng, GTIN_Number, arrows, GTIN_MaxChars, 5l, GT_Underscore, '_', TAG_DONE );
  420.  
  421.         SetStringGadget( g );
  422.  
  423.         sr_Gadgets[ GD_ARROWS ] = g;
  424.  
  425.         ng.ng_TopEdge       =   btop + 148;
  426.         ng.ng_Height        =   13;
  427.         ng.ng_GadgetText    =   "T_ext Place";
  428.         ng.ng_GadgetID      =   GD_TEXTPLACE;
  429.  
  430.         g = CreateGadget( CYCLE_KIND, g, &ng, GTCY_Labels, (Tag)cycle, GTCY_Active, place, GT_Underscore, (Tag)'_', TAG_DONE );
  431.  
  432.         sr_Gadgets[ GD_TEXTPLACE ] = g;
  433.  
  434.         ng.ng_LeftEdge      =   bleft + 8;
  435.         ng.ng_TopEdge       =   btop + 165;
  436.         ng.ng_Width         =   90;
  437.         ng.ng_GadgetText    =   "_OK";
  438.         ng.ng_Flags         =   PLACETEXT_IN;
  439.         ng.ng_GadgetID      =   GD_OK;
  440.  
  441.         g = CreateGadget( BUTTON_KIND, g, &ng, GT_Underscore, (Tag)'_', TAG_DONE );
  442.  
  443.         ng.ng_LeftEdge      =   bleft + 202;
  444.         ng.ng_GadgetText    =   "_CANCEL";
  445.         ng.ng_GadgetID      =   GD_CANCEL;
  446.  
  447.         g = CreateGadget( BUTTON_KIND, g, &ng, GT_Underscore, (Tag)'_', TAG_DONE );
  448.  
  449.         if ( g ) {
  450.  
  451.             sr_nwTags[6].ti_Data = (Tag)sr_GList;
  452.  
  453.             if ( sr_Wnd = OpenWindowTagList( 0l, sr_nwTags )) {
  454.  
  455.                 sr_Zoom[0] = l;
  456.                 sr_Zoom[1] = t;
  457.                 sr_Zoom[2] = w;
  458.                 sr_Zoom[3] = h;
  459.  
  460.                 GT_RefreshWindow( sr_Wnd, 0l );
  461.  
  462.                 do {
  463.                     WaitPort( sr_Wnd->UserPort );
  464.  
  465.                     while ( ReadIMsg( sr_Wnd )) {
  466.  
  467.                         switch ( Class ) {
  468.  
  469.                             case    IDCMP_REFRESHWINDOW:
  470.                                 GT_BeginRefresh( sr_Wnd );
  471.                                 GT_EndRefresh( sr_Wnd, TRUE );
  472.                                 break;
  473.  
  474.                             case    IDCMP_CLOSEWINDOW:
  475.                                 running = FALSE;
  476.                                 break;
  477.  
  478.                             case    IDCMP_GADGETDOWN:
  479.                                 switch( theObject->GadgetID ) {
  480.  
  481.                                     case    GD_LORIENT:
  482.                                         if ( NOT Code ) sr_Lorient = LORIENT_HORIZ;
  483.                                         else            sr_Lorient = LORIENT_VERT;
  484.                                         break;
  485.                                 }
  486.                                 break;
  487.  
  488.                             case    IDCMP_GADGETUP:
  489.                                 switch( theObject->GadgetID ) {
  490.  
  491.                                     case    GD_UNDERSCORE:
  492.                                         FlipFlop( 0l, 0l, 0l, &sr_Score );
  493.                                         break;
  494.  
  495.                                     case    GD_DISABLED:
  496.                                         FlipFlop( 0l, 0l, 0l, &sr_Disabled );
  497.                                         break;
  498.  
  499.                                     case    GD_HIGHLABEL:
  500.                                         FlipFlop( 0l, 0l, 0l, &high );
  501.                                         break;
  502.  
  503.                                     case    GD_IMMEDIATE:
  504.                                         FlipFlop( 0l, 0l, 0l, &sr_Immediate );
  505.                                         break;
  506.  
  507.                                     case    GD_RELVERIFY:
  508.                                         FlipFlop( 0l, 0l, 0l, &sr_RelVerify );
  509.                                         break;
  510.  
  511.                                     case    GD_TOP:
  512.  
  513.                                         num = (( struct StringInfo * )sr_Gadgets[ GD_TOP ]->SpecialInfo )->LongInt;
  514.  
  515.                                         if ( num < 0 ) {
  516.                                             DisplayBeep( MainScreen );
  517.                                             GT_SetGadgetAttrs( sr_Gadgets[ GD_TOP ], sr_Wnd, 0l, GTIN_Number, 0l, TAG_DONE );
  518.                                         }
  519.                                         break;
  520.  
  521.                                     case    GD_TOTAL:
  522.  
  523.                                         num = (( struct StringInfo * )sr_Gadgets[ GD_TOTAL ]->SpecialInfo )->LongInt;
  524.  
  525.                                         if ( num < 0 ) {
  526.                                             DisplayBeep( MainScreen );
  527.                                             GT_SetGadgetAttrs( sr_Gadgets[ GD_TOTAL ], sr_Wnd, 0l, GTIN_Number, 0l, TAG_DONE );
  528.                                         }
  529.                                         break;
  530.  
  531.                                     case    GD_VISIBLE:
  532.  
  533.                                         num = (( struct StringInfo * )sr_Gadgets[ GD_VISIBLE ]->SpecialInfo )->LongInt;
  534.  
  535.                                         if ( num < 0 ) {
  536.                                             DisplayBeep( MainScreen );
  537.                                             GT_SetGadgetAttrs( sr_Gadgets[ GD_VISIBLE ], sr_Wnd, 0l, GTIN_Number, 0l, TAG_DONE );
  538.                                         }
  539.                                         break;
  540.  
  541.                                     case    GD_ARROWS:
  542.  
  543.                                         num = (( struct StringInfo * )sr_Gadgets[ GD_TOP ]->SpecialInfo )->LongInt;
  544.  
  545.                                         if ( num < 0 ) {
  546.                                             DisplayBeep( MainScreen );
  547.                                             GT_SetGadgetAttrs( sr_Gadgets[ GD_ARROWS ], sr_Wnd, 0l, GTIN_Number, 0l, TAG_DONE );
  548.                                         }
  549.                                         break;
  550.  
  551.                                     case    GD_TEXTPLACE:
  552.                                         if ( place++ == 3 )
  553.                                             place = 0;
  554.  
  555.                                         flag = PlaceFlags[ place + 1 ];
  556.                                         break;
  557.  
  558.                                     case    GD_OK:
  559.                                         Ok:
  560.                                         ok = TRUE;
  561.  
  562.                                     case    GD_CANCEL:
  563.                                         Cancel:
  564.                                         running = FALSE;
  565.                                         break;
  566.                                 }
  567.                                 break;
  568.  
  569.                             case    IDCMP_VANILLAKEY:
  570.                                 switch( Code ) {
  571.  
  572.                                     case    't':
  573.                                         ID = GD_TEXT;
  574.                                         goto Activate;
  575.  
  576.                                     case    'l':
  577.                                         ID = GD_LABEL;
  578.                                         goto Activate;
  579.  
  580.                                     case    'u':
  581.                                         FlipFlop( sr_Wnd, sr_Gadgets, GD_UNDERSCORE, &sr_Score );
  582.                                         break;
  583.  
  584.                                     case    'd':
  585.                                         FlipFlop( sr_Wnd, sr_Gadgets, GD_DISABLED, &sr_Disabled );
  586.                                         break;
  587.  
  588.                                     case    'h':
  589.                                         FlipFlop( sr_Wnd, sr_Gadgets, GD_HIGHLABEL, &high );
  590.                                         break;
  591.  
  592.                                     case    'i':
  593.                                         FlipFlop( sr_Wnd, sr_Gadgets, GD_IMMEDIATE, &sr_Immediate );
  594.                                         break;
  595.  
  596.                                     case    'r':
  597.                                         FlipFlop( sr_Wnd, sr_Gadgets, GD_RELVERIFY, &sr_RelVerify );
  598.                                         break;
  599.  
  600.                                     case    'z':
  601.                                         sr_Lorient = LORIENT_HORIZ;
  602.                                         GT_SetGadgetAttrs( sr_Gadgets[ GD_LORIENT ], sr_Wnd, 0l, GTMX_Active, 0l, TAG_DONE );
  603.                                         break;
  604.  
  605.                                     case    'v':
  606.                                         sr_Lorient = LORIENT_VERT;
  607.                                         GT_SetGadgetAttrs( sr_Gadgets[ GD_LORIENT ], sr_Wnd, 0l, GTMX_Active, 1l, TAG_DONE );
  608.                                         break;
  609.  
  610.                                     case    'p':
  611.                                         ID = GD_TOP;
  612.                                         goto Activate;
  613.  
  614.                                     case    'a':
  615.                                         ID = GD_TOTAL;
  616.                                         goto Activate;
  617.  
  618.                                     case    's':
  619.                                         ID = GD_VISIBLE;
  620.                                         goto Activate;
  621.  
  622.                                     case    'w':
  623.                                         ID = GD_ARROWS;
  624.                                         goto Activate;
  625.  
  626.                                     case    'e':
  627.                                         if ( place++ == 3 )
  628.                                             place = 0;
  629.  
  630.                                         flag = PlaceFlags[ place + 1 ];
  631.                                         GT_SetGadgetAttrs( sr_Gadgets[ GD_TEXTPLACE ], sr_Wnd, 0l, GTCY_Active, place, TAG_DONE );
  632.                                         break;
  633.  
  634.                                     case    'o':
  635.                                         goto Ok;
  636.  
  637.                                     case    'c':
  638.                                         goto Cancel;
  639.                                 }
  640.                                 break;
  641.                                 Activate:
  642.                                 ActivateGadget( sr_Gadgets[ ID ], sr_Wnd, 0l );
  643.                                 break;
  644.                         }
  645.                     }
  646.                 } while ( running );
  647.             }
  648.         }
  649.     }
  650.  
  651.     if ( ok) {
  652.         if ( high ) flag |= NG_HIGHLABEL;
  653.  
  654.         ngFlags     =   flag;
  655.         ngLeft      =   x;
  656.         ngTop       =   y;
  657.         ngWidth     =   gw;
  658.         ngHeight    =   gh;
  659.         if ( NOT edit )
  660.             ok = MakeScroller();
  661.         else {
  662.             RemoveAllGadgets();
  663.             ChangeScroller( e );
  664.             Renumber();
  665.             ok = RemakeAllGadgets();
  666.         }
  667.     } else if ( NOT edit )
  668.         Box( x, y, x1, y1 );
  669.  
  670.     if ( sr_Wnd )           CloseWindow( sr_Wnd );
  671.     if ( sr_GList )         FreeGadgets( sr_GList );
  672.  
  673.     sr_Wnd     = 0l;
  674.     sr_GList   =  0l;
  675.  
  676.     ClearMsgPort( MainWindow->UserPort );
  677.  
  678.     return( (long)ok );
  679. }
  680.